Text area
Enables users to input multiple lines of text. Ideal for free-form responses, comments, or descriptions.
#Examples
#Default
The default variant is a blank field ready for user input. It visually indicates that it is interactive and accepts text. You can wrap FormElementWrapper
around the TextArea
to provide labelling and supplemental information.
Use cases:
- Long-form text input (comments, descriptions, reviews).
- Open-ended questions in forms.
- Any situation where a single line of text is insufficient.
const [value, setValue] = useState("");
return <TextArea placeholder="Placeholder text" value={value} onChange={setValue} />;
#Disabled
A disabled variant is visually distinct, appearing grayed out. It cannot be interacted with and does not accept input.
Best practices:
- When the information is for display only.
- When certain conditions haven't been met (e.g., a form field becomes enabled after another is filled out).
- To prevent accidental changes to existing text.
const [value, setValue] = useState("");
return <TextArea placeholder="Disabled" value={value} onChange={setValue} disabled />;
#Invalid
An invalid variant has a red border or visual cue to indicate an error (e.g., the text entered doesn't match the required format).
Best practices:
- When input validation fails.
- To clearly communicate errors to the user and help them fix the issue.
Error Handling:
- Provide clear and specific error messages immediately below the text area.
- Guide users on how to fix the issue
- Use inline validation to give real-time feedback as users type. Wrap
FormElementWrapper
around theTextArea
to provide labelling and supplemental information.
const [value, setValue] = useState("");
return <TextArea placeholder="This is invalid" value={value} onChange={setValue} invalid />;
#Properties
<undefined placeholder="Placeholder text" value="value" onChange={() => {...}} />
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications